package com.wx.registerclient.context;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 存放调用方法的地址与方法名的映射关系
 * 存放到map集合中
 */
@Component
public class PathAdnMethodMappingContext {
    // 保存方法与路径映射
    private final Map<String, String> pathMapping =new HashMap<>();

    // 方法与服务名的对应关系
  private final Map<String, String> methodSignatureAndServerName=new HashMap<>();

    /**
     * 存放方法名与路径映射
     * @param methodName
     * @param path
     */
    public void putMapping(String methodName,String path){

        pathMapping.put(methodName, path);
    }
    /**
     * 依据方法名获得对应的路径
     */
    public String getPathByMethodName(String name){
        return pathMapping.get(name);
    }

    public void putMesg2SignatureAndServerName(String signature,String name){
        methodSignatureAndServerName.put(signature,name);
    }

    public String getServerNameBySignature(String signature){
        return methodSignatureAndServerName.get(signature);
    }

}
